package com.example.elasticsearch.dao;

import com.example.elasticsearch.domain.Product;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Highlight;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <pre>
 * 接口定义规范：<a href="https://docs.spring.io/spring-data/elasticsearch/docs/4.1.2/reference/html/#repositories.query-methods.query-creation">...</a>
 * 可以不写实现类，但是命名必须规范
 * 特殊参数：https://docs.spring.io/spring-data/elasticsearch/docs/4.1.2/reference/html/#repositories.special-parameters
 * 限制查询结果：https://docs.spring.io/spring-data/elasticsearch/docs/4.1.2/reference/html/#repositories.limit-query-result
 * </pre>
 *
 * @author: 李明杰
 * @date: 2022/6/26 23:11
 */
@Repository
public interface ProductDao extends ElasticsearchRepository<Product, Long> {
    @Highlight(fields = {
            @HighlightField(name = "title")
    })
    List<Product> findByTitleOrderByIdDesc(String title, Pageable pageable);

    List<Product> findByPriceBetween(Double lowerBound, Double upperBound);

}
